package com.ktwlsoft.archivemanage.controller.sonWeb;

import com.ktwlsoft.archivemanage.domain.business.businessService.AdNotifyService;
import com.ktwlsoft.archivemanage.domain.dao.entity.AdNotify;
import com.ktwlsoft.archivemanage.payload.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * 用户子系统web通知查看
 *
 * @author zhuhe on 2019/11/27 14:18
 * @version 1.0
 */
@Api(value = "用户子系统web通知查看", description = "用户子系统web通知查看")
@RestController
@RequestMapping("sonWebAdNotify")
public class SonWebAdNotifyController {

    private final AdNotifyService adNotifyService;

    public SonWebAdNotifyController(AdNotifyService adNotifyService) {
        this.adNotifyService = adNotifyService;
    }

    /**
     * 通知查看列表 on 2019/10/24 17:02
     *
     * @return ResponseEntity<?>
     */
    @ApiOperation(value = "通知查看列表", httpMethod = "GET", produces = "application/json", response = ResponseEntity.class)
    @ResponseBody
    @GetMapping(value = "findPage")
    public ResponseEntity<?> findPage(@RequestParam(defaultValue = "1") int pn,
                                      @RequestParam(defaultValue = "30") int pageSize,
                                      @ApiParam("状态") AdNotify.State state,
                                      @ApiParam("操作时间起") String operateFrom,
                                      @ApiParam("操作时间止") String operateTo,
                                      @ApiParam("操作人") String operatorId,
                                      @ApiParam("关键字") String keywords){
        if(state == null){
            state = AdNotify.State.UP;
        }
        return ResponseEntity.ok(Result.ok(adNotifyService.sonFindAll(pn,pageSize,state,operateFrom,operateTo,operatorId,keywords)));
    }

    /**
     * 通知查看详情 on 2019/10/24 17:02
     *
     * @return ResponseEntity<?>
     */
    @ApiOperation(value = "通知查看详情", httpMethod = "GET", produces = "application/json", response = ResponseEntity.class)
    @ResponseBody
    @GetMapping(value = "getDetails")
    public ResponseEntity<?> getDetails(@ApiParam(name = "id", value = "通知id") @RequestParam(defaultValue = "", required = true) Long id){
        return ResponseEntity.ok(adNotifyService.getById(id));
    }
}